Inspector: Show more misc info about widgets
authorMatthias Clasen <mclasen@redhat.com>
Fri, 24 Oct 2014 11:49:37 +0000 (07:49 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 24 Oct 2014 12:34:13 +0000 (08:34 -0400)
This adds clip area, accessible role, mapped, realize,
is-toplevel, child-visible, mnemonic labels and tick
callbacks to the displayed information.

gtk/inspector/misc-info.c
gtk/inspector/misc-info.ui
gtk/inspector/misc-info.ui.h

index efb0e6cebc45d6ed6bad170fc6848d0c823f21e6..7f2db290bdcc4a60657cb8751412901db64b958d 100644 (file)
@@ -27,6 +27,9 @@
 #include "gtkbuildable.h"
 #include "gtklabel.h"
 #include "gtkframe.h"
+#include "gtkbutton.h"
+#include "gtkwidgetprivate.h"
+
 
 struct _GtkInspectorMiscInfoPrivate {
   GtkInspectorObjectTree *object_tree;
@@ -43,8 +46,24 @@ struct _GtkInspectorMiscInfoPrivate {
   GtkWidget *focus_widget_row;
   GtkWidget *focus_widget;
   GtkWidget *focus_widget_button;
+  GtkWidget *mnemonic_label_row;
+  GtkWidget *mnemonic_label;
   GtkWidget *allocated_size_row;
   GtkWidget *allocated_size;
+  GtkWidget *clip_area_row;
+  GtkWidget *clip_area;
+  GtkWidget *tick_callback_row;
+  GtkWidget *tick_callback;
+  GtkWidget *accessible_role_row;
+  GtkWidget *accessible_role;
+  GtkWidget *mapped_row;
+  GtkWidget *mapped;
+  GtkWidget *realized_row;
+  GtkWidget *realized;
+  GtkWidget *is_toplevel_row;
+  GtkWidget *is_toplevel;
+  GtkWidget *child_visible_row;
+  GtkWidget *child_visible;
 };
 
 enum
@@ -97,12 +116,31 @@ state_flags_changed (GtkWidget *w, GtkStateFlags old_flags, GtkInspectorMiscInfo
 static void
 allocation_changed (GtkWidget *w, GdkRectangle *allocation, GtkInspectorMiscInfo *sl)
 {
-  gchar *size_label = g_strdup_printf ("%d × %d",
-                                       gtk_widget_get_allocated_width (w),
-                                       gtk_widget_get_allocated_height (w));
+  GtkAllocation clip;
+  gchar *size_label;
+
+  size_label = g_strdup_printf ("%d × %d",
+                                gtk_widget_get_allocated_width (w),
+                                gtk_widget_get_allocated_height (w));
 
   gtk_label_set_label (GTK_LABEL (sl->priv->allocated_size), size_label);
   g_free (size_label);
+
+  gtk_widget_get_clip (w, &clip);
+
+  if (clip.width == gtk_widget_get_allocated_width (w) &&
+      clip.height == gtk_widget_get_allocated_height (w))
+    {
+      gtk_widget_hide (sl->priv->clip_area_row);
+    }
+  else
+    {
+      gtk_widget_show (sl->priv->clip_area_row);
+
+      size_label = g_strdup_printf ("%d × %d", clip.width, clip.height);
+      gtk_label_set_label (GTK_LABEL (sl->priv->clip_area), size_label);
+      g_free (size_label);
+    }
 }
 
 static void
@@ -214,6 +252,16 @@ show_focus_widget (GtkWidget *button, GtkInspectorMiscInfo *sl)
     show_object (sl, G_OBJECT (widget), NULL, "properties"); 
 }
 
+static void
+show_mnemonic_label (GtkWidget *button, GtkInspectorMiscInfo *sl)
+{
+  GtkWidget *widget;
+
+  widget = g_object_get_data (G_OBJECT (button), "mnemonic-label");
+  if (widget)
+    show_object (sl, G_OBJECT (widget), NULL, "properties");
+}
+
 void
 gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
                                     GObject              *object)
@@ -242,18 +290,67 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
 
   if (GTK_IS_WIDGET (object))
     {
+      AtkObject *accessible;
+      AtkRole role;
+      GList *list, *l;
+
       gtk_widget_show (sl->priv->state_row);
       g_signal_connect_object (object, "state-flags-changed", G_CALLBACK (state_flags_changed), sl, 0);
       state_flags_changed (GTK_WIDGET (sl->priv->object), 0, sl);
 
+      gtk_widget_show (sl->priv->mnemonic_label_row);
+      gtk_container_forall (GTK_CONTAINER (sl->priv->mnemonic_label), (GtkCallback)gtk_widget_destroy, NULL);
+      list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->priv->object));
+      for (l = list; l; l = l->next)
+        {
+          gchar *tmp;
+          GtkWidget *button;
+
+          tmp = g_strdup_printf ("%p (%s)", l->data, g_type_name_from_instance ((GTypeInstance*)l->data));
+          button = gtk_button_new_with_label (tmp);
+          gtk_widget_show (button);
+          gtk_container_add (GTK_CONTAINER (sl->priv->mnemonic_label), button);
+          g_object_set_data (G_OBJECT (button), "mnemonic-label", l->data);
+          g_signal_connect (button, "clicked", G_CALLBACK (show_mnemonic_label), sl);
+        }
+      g_list_free (list);
+
       allocation_changed (GTK_WIDGET (sl->priv->object), NULL, sl);
       gtk_widget_show (sl->priv->allocated_size_row);
       g_signal_connect_object (object, "size-allocate", G_CALLBACK (allocation_changed), sl, 0);
+
+      gtk_widget_set_visible (sl->priv->tick_callback, gtk_widget_has_tick_callback (GTK_WIDGET (sl->priv->object)));
+      gtk_widget_show (sl->priv->tick_callback_row);
+
+      accessible = ATK_OBJECT (gtk_widget_get_accessible (GTK_WIDGET (sl->priv->object)));
+      role = atk_object_get_role (accessible);
+      gtk_label_set_text (GTK_LABEL (sl->priv->accessible_role), atk_role_get_name (role));
+      gtk_widget_show (sl->priv->accessible_role_row);
+
+      gtk_widget_set_visible (sl->priv->mapped, gtk_widget_get_mapped (GTK_WIDGET (sl->priv->object)));
+      gtk_widget_show (sl->priv->mapped_row);
+
+      gtk_widget_set_visible (sl->priv->realized, gtk_widget_get_realized (GTK_WIDGET (sl->priv->object)));
+      gtk_widget_show (sl->priv->realized_row);
+
+      gtk_widget_set_visible (sl->priv->is_toplevel, gtk_widget_is_toplevel (GTK_WIDGET (sl->priv->object)));
+      gtk_widget_show (sl->priv->is_toplevel_row);
+
+      gtk_widget_set_visible (sl->priv->child_visible, gtk_widget_get_child_visible (GTK_WIDGET (sl->priv->object)));
+      gtk_widget_show (sl->priv->is_toplevel_row);
     }
   else
     {
       gtk_widget_hide (sl->priv->state_row);
+      gtk_widget_hide (sl->priv->mnemonic_label_row);
       gtk_widget_hide (sl->priv->allocated_size_row);
+      gtk_widget_hide (sl->priv->clip_area_row);
+      gtk_widget_hide (sl->priv->tick_callback_row);
+      gtk_widget_hide (sl->priv->accessible_role_row);
+      gtk_widget_hide (sl->priv->mapped_row);
+      gtk_widget_hide (sl->priv->realized_row);
+      gtk_widget_hide (sl->priv->is_toplevel_row);
+      gtk_widget_hide (sl->priv->child_visible_row);
     }
 
   if (GTK_IS_BUILDABLE (object))
@@ -355,8 +452,24 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget_row);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget_button);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mnemonic_label_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mnemonic_label);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, allocated_size_row);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, allocated_size);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, clip_area_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, clip_area);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, tick_callback_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, tick_callback);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_role_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_role);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mapped_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mapped);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, realized_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, realized);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, is_toplevel_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, is_toplevel);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible);
 
   gtk_widget_class_bind_template_callback (widget_class, show_default_widget);
   gtk_widget_class_bind_template_callback (widget_class, show_focus_widget);
index eceb9b51e98dae2bc3c8a0389234ec514aa94bde..ad0a0960b695ed2375bf2f6e0d567f70a7ee0edc 100644 (file)
                   </object>
                 </child>
 
+                <child>
+                  <object class="GtkListBoxRow" id="mnemonic_label_row">
+                    <property name="visible">True</property>
+                    <property name="activatable">False</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Mnemonic Label</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0.0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="mnemonic_label">
+                            <property name="visible">True</property>
+                            <property name="orientation">horizontal</property>
+                            <property name="spacing">10</property>
+                            <property name="halign">end</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
                 <child>
                   <object class="GtkListBoxRow" id="allocated_size_row">
                     <property name="visible">true</property>
                   </object>
                 </child>
 
+                <child>
+                  <object class="GtkListBoxRow" id="clip_area_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Clip area</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="clip_area">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBoxRow" id="tick_callback_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Tick callback</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="tick_callback">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                            <property name="icon-name">object-select-symbolic</property>
+                            <property name="icon-size">1</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBoxRow" id="accessible_role_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Accessible role</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="accessible_role">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBoxRow" id="mapped_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Mapped</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="mapped">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                            <property name="icon-size">1</property>
+                            <property name="icon-name">object-select-symbolic</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBoxRow" id="realized_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Realized</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="realized">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                            <property name="icon-size">1</property>
+                            <property name="icon-name">object-select-symbolic</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBoxRow" id="is_toplevel_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Is Toplevel</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="is_toplevel">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                            <property name="icon-size">1</property>
+                            <property name="icon-name">object-select-symbolic</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBoxRow" id="child_visible_row">
+                    <property name="visible">true</property>
+                    <property name="activatable">false</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">true</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="margin">10</property>
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">true</property>
+                            <property name="label" translatable="yes">Child Visible</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">true</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="child_visible">
+                            <property name="visible">true</property>
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                            <property name="icon-size">1</property>
+                            <property name="icon-name">object-select-symbolic</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
               </object>
             </child>
           </object>
     </widgets>
   </object>
 </interface>
+
index b78feec93a4b4e6482b097136d3fc3981bbb8af6..6d954ce358379cbe03eeca4f391e81b2cfa5c276 100644 (file)
@@ -4,4 +4,12 @@ N_("Default Widget");
 N_("Properties");
 N_("Focus Widget");
 N_("Properties");
+N_("Mnemonic Label");
 N_("Allocated size");
+N_("Clip area");
+N_("Tick callback");
+N_("Accessible role");
+N_("Mapped");
+N_("Realized");
+N_("Is Toplevel");
+N_("Child Visible");